const mongoose = require('mongoose')
const Schema = mongoose.Schema
const { name } = require('../public/javascripts/utils');
//  文章

const schema = new Schema({
  title: { type: String, required: true }, // 文章标题
  content: { type: String, required: true }, // 文章内容
  directoryId: { type: Schema.Types.ObjectId, ref: 'directories', required: true }, // 所属目录的唯一标识
  createdAt: { type: Date, default: Date.now }, // 创建时间
  updatedAt: { type: Date, default: Date.now }, // 更新时间
  authorId: { type: Schema.Types.ObjectId, ref: 'users', required: true }, // 作者的唯一标识
  tags: { type: [String], default: [] }, // 文章标签
  views: { type: Number, default: 0 }, // 文章浏览次数
  likes: { type: Number, default: 0 } // 文章点赞数
});

module.exports = mongoose.model(name(__filename), schema)